<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of BaiduDecoratorDesc
 *
 * @author Implement <hdjahs@qq.com>
 */
class BaiduDecoratorDesc {

    private $obj;

    public function __construct(Baidu $obj) {
        $this->obj = $obj;
        $this->init();
    }

    private function init() {  
        $preg = '/<div class="para" label-module="para">(.*)<\/div>/';
        preg_match_all($preg, $this->obj->result, $result);
        $desc = (isset($result[0][0]) ? $result[0][0] : '') . (isset($result[0][1]) ? $result[0][1] : '') . (isset($result[0][2]) ? $result[0][2] : '');
        $desc = strip_tags($desc);
        $desc = substr($desc, 0, strrpos($desc, '。')) . '。';
        $this->obj->str .= "\n" . $desc;
    }

}
